home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / C005.ZIP / AMORTIZ / AMORTIZ3.C < prev    next >
Text File  |  1990-01-19  |  2KB  |  95 lines

  1. /********************************************************************
  2.  * C Users Group (U.K) C Source Code Library File CUGLIB.005        *
  3.  * Inquiries to: M. Houston, 36 Whetstone Clo. Farquhar Rd.         *
  4.  * Edgbaston, Birmingham B15 2QN ENGLAND                *
  5.  ********************************************************************
  6.  * File name: amortiz3.c
  7.  * Program name: 
  8.  * Source of file: The Public Domain Software Library.
  9.  * Purpose: interest rate calculations.
  10.  * Changes: <who what when & why major changes have been made>      
  11.  ********************************************************************/
  12.  
  13. /*
  14. amount = starting balance
  15. balance = remaining balance
  16. rate = interest rate per period
  17. rate1 = interest rate per year
  18. payment = monthly payment
  19. principal = payment to principle
  20. interest = payment of interest per period
  21.  
  22. *******************************************************/
  23. /*        declare variables        */
  24.  
  25.     float amount;
  26.     float balance =0;
  27.     float rate1;
  28.     float rate;
  29.     float payment;
  30.     float principal = 0;
  31.     float interest = 0;
  32.  
  33. /*    **************************    */
  34. interest1()    /* call compute and print results    */
  35. {
  36.     
  37.         balance = amount;
  38.         int x =0;
  39.  
  40.         printf(" payment   interest   principal   balance\n");
  41.  
  42.     while (balance >0)    /* call compute and print results */
  43.         {
  44.         compute();
  45.         printf("%8.2f  %8.2f  %8.2f    %8.2f   %d\n",payment, interest,
  46.                                              principal, balance, ++x);
  47.         line();
  48.         
  49.             if (x%12 ==0)    /* pause every 12 payments  */
  50.                 {
  51.                 printf("press return");
  52.                 getchar();
  53.                 }
  54.  
  55.         }
  56.     
  57. }
  58.  
  59.  
  60. /*        compute balance        */
  61.     compute()
  62.         {
  63.  
  64.         if (balance > payment)
  65.             {
  66.             interest = balance * rate;
  67.             principal = payment - interest;
  68.             balance = balance - principal;
  69.             return (interest);
  70.             return (principal);
  71.             return (balance);
  72.             }
  73.         else
  74.             {
  75.             interest = balance * rate;
  76.             payment = balance + interest;
  77.             principal = payment - interest;
  78.             balance = balance - principal;
  79.             return (interest);
  80.             return (payment);
  81.             return (principal);
  82.             return (balance);
  83.             }
  84.         }
  85.  
  86.  
  87. line()
  88.     {
  89.     int x = 0;
  90.         while (x++<=79)
  91.             printf("-");
  92.         
  93.     }
  94.  
  95.